import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/device/lock/electronic_key/widgets/send_key/limited.dart";
import "package:ct_pa_majordomo/pages/device/lock/electronic_key/widgets/send_key/permanent.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";

class SendKey extends StatefulWidget {
  final int lockId;
  const SendKey({super.key, required this.lockId});

  @override
  State<StatefulWidget> createState() => _SendKeyState();

}

class _SendKeyState extends State<SendKey> {

  final List _tabs = ["限时", "永久"];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: _tabs.length,
      child: Scaffold(
        appBar: AppBar(
          iconTheme: const IconThemeData(color: Colors.white),
          title: const Text("锁管理", style: TextStyle(color: Colors.white),),
          centerTitle: true,
          backgroundColor: ThemeVars.colorPrimaryDark,
          leading: IconButton(
            icon: const Icon(Icons.arrow_back_ios_new),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          bottom: PreferredSize(
              preferredSize: const Size.fromHeight(48),
              child: Material(
                color: Colors.white,
                child: TabBar(
                  tabs: List.generate(_tabs.length, (index) => Tab(text: _tabs[index],)),
                ),
              )
          ),
        ),
        body: TabBarView(
          children: [
            Limited(lockId: widget.lockId),
            Permanent(lockId: widget.lockId),
          ],
        ),
      ),
    );
  }

}